﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title>WorkersWagesMonitoringReport</title>
    <link id="easyuiTheme" href="/Res/easyui/themes/metro/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Content/default.css" rel="stylesheet" />

    <script src="/Scripts/jquery-1.8.3.min.js"></script>
    <script src="/Res/easyui/jquery.easyui.min.js"></script>
    <script src="/Res/easyui/jquery.cookie.js"></script>
    <script src="/Res/easyui/locale/easyui-lang-zh_CN.js"></script>

    <script type="text/javascript">
        $(function () {
            $('#hProjectID').val("<%=Request.Params["ProjectID"]%>");
            $('#hContractType').val("<%=Request.Params["ContractType"]%>");
            $('#hContractID').val("<%=Request.Params["ContractID"]%>");
            $('#hYear').val("<%=Request.Params["Year"]%>");
            $('#hMonth').val("<%=Request.Params["Month"]%>");

            $('#ContractType').combobox({
                editable: false, panelHeight: "auto",
                valueField: "DictionaryName",
                textField: "DictionaryName",
                url: "/Dictionary/GetDictionaryByTypeTag?typeTag=ContractType",
                onLoadSuccess: function () {
                    var data = $('#ContractType').combobox('getData');
                    if (data.length > 0) {
                        if ($('#hContractType').val() != '') {
                            $('#ContractType').combobox('select', ($('#hContractType').val()));
                        }
                        else {
                            $('#ContractType').combobox('select', data[0]["DictionaryName"]);
                        }
                    }
                    $('#hContractType').val('');
                },
                onSelect: function (record) {
                    var projectID = $("#ProjectID").combobox('getValue');
                    initContract(projectID, record.DictionaryName);
                }
            });

            $("#ProjectID").combobox({
                editable: false, panelHeight: "auto",
                valueField: 'ID',
                textField: 'ProjectName',
                url: '/ProjectInfo/ProjectInfoListForFlow',
                onLoadSuccess: function () {
                    var data = $("#ProjectID").combobox('getData');
                    if (data.length > 0) {
                        if ($('#hProjectID').val() != '') {
                            $('#ProjectID').combobox('select', ($('#hProjectID').val()));
                        }
                        else {
                            $("#ProjectID").combobox('select', data[0]["ID"]);
                        }
                    }
                    $('#hProjectID').val('');
                },
                onSelect: function (record) {
                    var contractType = $("#ContractType").combobox('getValue');
                    initContract(record.ID, contractType);
                }
            });

            $("#Year").combobox({
                editable: false, panelHeight: "auto",
                valueField: "DictionaryName",
                textField: "DictionaryName",
                url: "/Dictionary/GetDictionaryByTypeTag?typeTag=Year",
                onLoadSuccess: function () {
                    var data = $('#Year').combobox('getData');
                    if (data.length > 0) {
                        if ($('#hYear').val() != '') {
                            $('#Year').combobox('select', ($('#hYear').val()));
                        }
                        else {
                            $('#Year').combobox('select', data[0]["DictionaryName"]);
                        }
                    }
                    $('#hYear').val('');
                }
            });

            $("#Month").combobox({
                editable: false, panelHeight: "auto",
                valueField: "DictionaryName",
                textField: "DictionaryName",
                url: "/Dictionary/GetDictionaryByTypeTag?typeTag=Month",
                onLoadSuccess: function () {
                    var data = $("#Month").combobox('getData');
                    if (data.length > 0) {
                        if ($('#hMonth').val() != '') {
                            $('#Month').combobox('select', ($('#hMonth').val()));
                        }
                        else {
                            $("#Month").combobox('select', data[0]["DictionaryName"]);
                        }
                    }
                    $('#hMonth').val('');
                }
            });
        });

        function initContract(projectID, contractType) {
            $("#ContractID").combobox({
                editable: false, panelHeight: "auto",
                valueField: 'ID',
                textField: 'ContractName',
                url: '/ContractInfo/ContractInfoListByProjectIDAndType?projectID=' + projectID + '&contractType=' + encodeURI(contractType),
                onLoadSuccess: function () {
                    var data = $("#ContractID").combobox('getData');
                    if (data.length > 0) {
                        if ($('#hContractID').val() != '') {
                            $('#ContractID').combobox('select', ($('#hContractID').val()));
                        }
                        else {
                            $("#ContractID").combobox('select', data[0]["ID"]);
                        }
                        $('#hContractID').val('');
                    }
                }
            });
        }
    </script>

    <script runat="server">
        void Page_Load(object sender, EventArgs e)
        {
            if (ViewData["ReportData"] != null)
            {
                ReportViewer1.LocalReport.ReportPath = @"bin\Report\WorkersWagesMonitoringReport.rdlc";
                List<Bricks.Site.Models.SectionSalaryDetailsView> lstSectionSalaryDetailsView = ViewData["ReportData"] as List<Bricks.Site.Models.SectionSalaryDetailsView>;
                ReportDataSource source = new ReportDataSource();
                source.Name = "SectionSalaryDetails";
                source.Value = lstSectionSalaryDetailsView;
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(source);
                ReportParameter reportParameter = new ReportParameter();
                reportParameter.Name = "CurrentReportName";
                reportParameter.Values.Add(ViewData["CurrentReportName"] as string);
                ReportViewer1.LocalReport.SetParameters(reportParameter);
                ReportViewer1.ZoomMode = ZoomMode.PageWidth;
                ReportViewer1.LocalReport.Refresh();
            }
        }
    </script>
</head>
<body>
    <form id="frmWorkersWagesMonitoringReport" runat="server">
        <div>
            <input type="hidden" id="hProjectID" />
            <input type="hidden" id="hContractType" />
            <input type="hidden" id="hContractID" />
            <input type="hidden" id="hYear" />
            <input type="hidden" id="hMonth" />
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <%using (Html.BeginForm("WorkersWagesMonitoringReport", "ReportView"))
              {%>
            <table style="margin-top: 5px">
                <tr>
                    <td style="width: 95px; text-align: center">项目名称</td>
                    <td>
                        <input id="ProjectID" name="ProjectID" class="easyui-combobox" style="width: 180px;" />
                    </td>
                    <td style="width: 95px; text-align: center">合同类型</td>
                    <td>
                        <input id="ContractType" name="ContractType" class="easyui-combobox" style="width: 180px;" />
                    </td>
                    <td style="width: 95px; text-align: center">标段名称</td>
                    <td>
                        <input id="ContractID" name="ContractID" class="easyui-combobox" style="width: 180px;" />
                    </td>
                    <td style="width: 50px; text-align: center">年</td>
                    <td>
                        <input id="Year" name="Year" class="easyui-combobox" style="width: 70px;" />
                    </td>
                    <td style="width: 50px; text-align: center">月</td>
                    <td>
                        <input id="Month" name="Month" class="easyui-combobox" style="width: 70px;" />
                    </td>
                    <td>
                        <%--<asp:Button ID="btnGenerate" runat="server" Text="预览" />--%>
                        <input type="submit" value="预览" />
                    </td>
                </tr>
            </table>
            <%} %>
            <%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>--%>
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" AsyncRendering="false" Font-Names="Verdana" Font-Size="8pt" BackColor="#eaf6fc" Width="100%" Height="900px" ShowFindControls="false" ShowPrintButton="false">
            </rsweb:ReportViewer>
            <%-- </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnGenerate" />
                </Triggers>
            </asp:UpdatePanel>--%>
        </div>
    </form>
</body>
</html>
